//
//  JuliyeTabBarController.m
//  Zuisuigirveup
//
//  Created by spdbmacbook0003 on 2025/8/4.
//

#import "JuliyeTabBarController.h"
#import <YYWebImage/YYWebImage.h>
#import "UIColor+JLY.h"
#import "JuliyeShouyeViewController.h"
#import "JuliyeDierViewController.h"
#import "JuliyeSanViewController.h"
#import "JuliyeNavigationVC.h"
@interface JuliyeTabBarController ()
@property (nonatomic, strong)UIButton *selectBtn;
@property (nonatomic, strong)UIView *ksdlatabbarView;
@end

@implementation JuliyeTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tabBarController.tabBar.hidden = YES;
    
    [self setALLTabskdixjkas];
    
    JuliyeSanViewController *san = [JuliyeSanViewController new];
    JuliyeDierViewController *dier = [JuliyeDierViewController new];
    JuliyeShouyeViewController *shouye = [JuliyeShouyeViewController new];
    JuliyeNavigationVC *synav = [[JuliyeNavigationVC alloc]initWithRootViewController:shouye];
    JuliyeNavigationVC *duernav = [[JuliyeNavigationVC alloc]initWithRootViewController:dier];
    JuliyeNavigationVC *sannav = [[JuliyeNavigationVC alloc]initWithRootViewController:san];
    self.viewControllers = @[synav,duernav,sannav];
    
}
- (void)setALLTabskdixjkas{
    
    NSArray *tabbsdnak = @[@"Home",@"Order",@"My"];
    
    UIView *backSdhka = [[UIView alloc]initWithFrame:CGRectMake(JLYTap, JLYScreenHeight - JLYTabHeight,JLYScreenWidth - JLYTap*2, JLYTabbarViewHeight)];
    backSdhka.backgroundColor = [UIColor whiteColor];
    backSdhka.layer.cornerRadius = 5;
    backSdhka.layer.masksToBounds = YES;
    backSdhka.layer.shadowColor = (__bridge CGColorRef _Nullable)(UIColor.grayColor);
    backSdhka.layer.shadowRadius = 10;
    [self.view addSubview:backSdhka];
    CGFloat bbtnWidha = backSdhka.frame.size.width;
    for (int i = 0; i < tabbsdnak.count; i++) {
        UIButton *bsnda = [UIButton buttonWithType:UIButtonTypeCustom];
        [bsnda setTitle:tabbsdnak[i] forState:UIControlStateNormal];
        [bsnda setBackgroundImage:[UIImage yy_imageWithColor:[UIColor JLYGetColorWithHEX:@"#86CE60"]] forState:UIControlStateSelected];
        [bsnda setBackgroundImage:[UIImage yy_imageWithColor:[UIColor clearColor]] forState:UIControlStateNormal];
        [bsnda addTarget:self action:@selector(BottomTabbartnAction:) forControlEvents:UIControlEventTouchUpInside];
        bsnda.titleLabel.font = [UIFont systemFontOfSize:14];
        bsnda.tag = i;
        bsnda.frame = CGRectMake((i*bbtnWidha)/3.0, 10,bbtnWidha, 38);
        if(i == 0){
            self.selectBtn = bsnda;
        }
        [backSdhka addSubview:bsnda];
    }
    
}
- (void)BottomTabbartnAction:(UIButton *)btn{

    if(self.selectedIndex != btn.tag){
        btn.selected = !btn.selected;
        self.selectBtn = btn;
        self.selectedIndex = btn.tag;
    }else{
        
    }
}

@end
